<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ckeditor" uri="http://ckeditor.com" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="../../css/style.css">
<script type="text/javascript" src="../js/httpRequest.js"></script>
<script type="text/javascript" src="../common/se2/js/HuskyEZCreator.js" charset="utf-8"></script>

<script type="text/javascript">


function change_cate(value){
	var cate_no=value;
	//alert(value);
	if(cate_no=="")return;
	sendRequest("../ajax/get_title.jsp", "cate_no="+cate_no, resultTitle, "POST");
}

function resultTitle(){
	if(xhr.readyState==4 && xhr.status==200){
		var res=eval(xhr.responseText);
		var sel=document.getElementById("title_no");
		
		if(res.length>0){
			sel.options.length=1;
			for(var i=0; i <res.length; i++){
				var opt = document.createElement("OPTION");
				sel.appendChild(opt);
				opt.text= res[i].title_name;
				opt.value=res[i].title_no;
			}
		}else{
			sel.options.length=1;
		}
	}
}

/* function init_content(value){
	var title=value;
	if(title=="")return;
	sendRequest("get_content.jsp", "title="+encodeURIComponent(title), resultContent,"POST");
}  */

function check(){
	
	var category=document.getElementById("cate_no").value;
	var title=document.getElementById("title_no").value;
	var subject=f.s_subject.value;
	//var content=f.content.value;

	if(category==""){
		alert("카테고리가 선택되지 않았습니다!");
		return;
	}
	if(title==""){
		alert("타이틀이 선택되지 않았습니다!!");
		return;
	}
	if(subject==""){
		alert("제목을 입력하세요!!");
		return;
	}
	/* if(content==""){
		alert("내용을 입력하세요!!");
		return;
	} */
	f.action="study_write.do";
	f.submit();
}

function insertCtegory(){
	
}
function insertTitle(){
	
}
</script>
</head>
<body>
<div id="wrapper">
<div id="page">
	<div id="write">
	<form name="f" action="study_write.do" method="POST">
	<input type="hidden" name="menu_no" value="${param.menu_no }">
		<div >
			<div class="box">
				<table border="1" bordercolor="white">
						<tr>
						<td>
							Category:
						</td>
						<td>
							<select name="cate_no" id="cate_no" onchange="change_cate(this.value)">
								<option value="">::[Category]선택::</option>
							<c:forEach var="s" items="${study_cate }">
								<option value="${s.cate_no }">${s.cate_name }</option>
							</c:forEach>
							</select>
						
						</td>
						<td>
							Title:
						</td>
						<td width="200px">
							<select name="title_no" id="title_no" style="width: 200px;" >
								<option value="">::[Title]선택::</option>
							</select>
						</td>
						<td>
							Subject:
						</td>
						<td>
							<input type="text" name="s_subject">
						</td>
						
					</tr>
				</table>
			</div>
			
		</div><br class="clearfix" />

		<div>
			<div class="box" align="center">
				<textarea name="ir1" id="ir1" rows="22" style="width:645px;"></textarea>
			<script type="text/javascript">
 var oEditors = [];
 nhn.husky.EZCreator.createInIFrame({
 oAppRef: oEditors,
 elPlaceHolder: "ir1",
 sSkinURI: "../common/se2/SmartEditor2Skin.html",
 fCreator: "createSEditor2"
 });
</script>


			
			</div><br class="clearfix" />
			<ckeditor:replace replace="s_content" basePath="/_0730_Project_Main/ckeditor/"></ckeditor:replace>
		</div>
		<input type="button"  class="pink_button"  style="text-align: center;" value="저장" onclick="check()">
		</form>
		</div>
	</div>
	</div>
</body>
</html>